import { http } from "@/utils/http";

export type AsyncRouteType = {
  id: string;
  parentId: string;
  code: string;
  name: string;
  alias: string;
  path: string;
  source: string;
  sort: number;
  category: number;
  action: number;
  isOpen: number;
  remark: string;
  isDeleted: number;
  children: AsyncRouteType[];
  hasChildren: boolean;
  parentName: string;
  categoryName: string;
  actionName: string;
  isOpenName: string;
  // TODO: 后端需要添加
  frameSrc: string;
  frameLoading: boolean;
  frame: boolean;
};

export type RoutesResult = ReplaceTargetType<Array<AsyncRouteType>>;

/**
 * @description 获取后端权限菜单 (Cup)
 */
export const getAsyncRoutes = () => {
  return http.request<RoutesResult>("get", "/cupSystemApi/menu/routes");
};

/**
 * 获取后端按钮等配置权限 (Cup)
 */
export const getAsyncButton = () => {
  return http.request<RoutesResult>("get", "/cupSystemApi/menu/buttons");
};
